package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.ProductBrandRequest;
import com.ytjj.qmyx.admin.service.ProductBrandService;
import com.ytjj.qmyx.mall.model.ProductBrand;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 * 
 * @Version: 1.0
 */
@RestController
@RequestMapping("/productBrand")
public class ProductBrandController {

	@Resource
	private ProductBrandService productBrandService;

	@GetMapping("/brandList")
	public CommonResult getBrandList() {
		return CommonResult.success(productBrandService.getProductBrandList());
	}

	@GetMapping("/list")
	@OperLog(operModule = "品牌管理", operDesc = "列表", operType = SysLogConstants.OPERATION_SELECT)
	public CommonResult selectList(ProductBrandRequest request) {
		return CommonResult.success(productBrandService.selectList(request));
	}

	@PostMapping("/add")
	@OperLog(operModule = "品牌管理", operDesc = "新增", operType = SysLogConstants.OPERATION_ADD)
	public CommonResult addProductBrand(@RequestBody ProductBrand productBrand) {
		return CommonResult.success(productBrandService.addProductBrand(productBrand));
	}

	@PostMapping("/update")
	@OperLog(operModule = "品牌管理", operDesc = "编辑", operType = SysLogConstants.OPERATION_UPDATE)
	public CommonResult updateProductBrand(@RequestBody ProductBrand productBrand) {
		return CommonResult.success(productBrandService.udpateProductBrand(productBrand));
	}

	@GetMapping("/delete")
	@OperLog(operModule = "品牌管理", operDesc = "移除", operType = SysLogConstants.OPERATION_DELETE)
	public CommonResult deleteProductBrand(@RequestParam Integer id) {
		return CommonResult.success(productBrandService.deleteProductBrand(id));
	}

	@GetMapping("/findCountryAll")
	@OperLog(operModule = "品牌管理", operDesc = "列表", operType = SysLogConstants.OPERATION_SELECT)
	public CommonResult findCountryAll() {
		return CommonResult.success(productBrandService.findCountryAll());
	}
}
